package com.hnhs.service;

import com.hnhs.mapper.DcdDataDao;
import com.hnhs.model.Popular;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;

@Service
public class CsvService {
@Autowired
private DcdDataDao dcdDataDao;

//    public List<String> importCsvData(InputStream inputStream) {
//        List<String> duplicateRows = new ArrayList<>();
//
//        try (Reader reader = new InputStreamReader(inputStream);
//             Popular csvParser = new Popular(reader, CSVFormat.DEFAULT.withFirstRecordAsHeader())) {
//
//            for (CSVRecord record : csvParser) {
//                String field1 = record.get("field1");
//                String field2 = record.get("field2");
//                // 进行数据处理或保存到数据库等操作
//                YourEntity existingEntity = entityRepository.findByField1AndField2(field1, field2);
//                if (existingEntity != null) {
//                    duplicateRows.add("Row " + record.getRecordNumber() + " is a duplicate");
//                } else {
//                    // 保存到数据库或其他操作
//                }
//            }
//
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//        return duplicateRows;
//    }
//}



}
